package com.adou.Controller;

import com.adou.common.controller.BaseController;
import com.adou.common.util.EntityUtil;
import com.adou.common.util.EntityUtil.Entity;
import com.adou.service.FlowDesignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Scope(value = "prototype")
@RequestMapping("flowDesign")
public class FlowDesignController extends BaseController {

    @Autowired
    private FlowDesignService flowDesignService;

    /**
     * 根据流程主键查询流程图数据
     * @param fid
     * @return
     */
    @GetMapping("queryData")
    public Entity queryData(Long fid){
        try {
            return flowDesignService.queryData(fid);
        }
        catch (Exception e){
            logger.error(e.toString());
            return EntityUtil.error(100, e.getMessage());
        }
    }

    /**
     * 添加流程图数据
     * @param map
     * @return
     */
    @PostMapping("insertData")
    public Entity insertData(@RequestBody Map<String, Object> map){
        try {
            return flowDesignService.insertData(map);
        }
        catch (Exception e){
            logger.error(e.toString());
            return EntityUtil.error(200, e.getMessage());
        }
    }

}
